package gameEngine.com.state;

import java.sql.Date;

import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.Matrix;
import android.graphics.Paint.Style;
import android.view.KeyEvent;
import gameEngine.com.*;
import gameEngine.com.Actor.Actor;

public class StateEndLevel extends MainActivity {

	public static int NEXT_LEVEL_X = 50;
	public static int NEXT_LEVEL_Y = 300;
	public static int NEXT_LEVEL_W = 200;
	public static int NEXT_LEVEL_H = 100;
	public static int RETRY_X = 300;
	public static int RETRY_Y = 300;
	public static int RETRY_W = 200;
	public static int RETRY_H = 100;
	public static int MAIN_MENU_X = 550;
	public static int MAIN_MENU_Y = 300;
	public static int MAIN_MENU_W = 200;
	public static int MAIN_MENU_H = 100;

	public static void SendMessageStateStateEndLevel(int type) {

		switch (type) {
		case MESSAGE_CTOR:
			//need check condition at here
			 //StateGameplay.level++;
			break;
		case MESSAGE_UPDATE:
			if (isTouchReleaseInRect(NEXT_LEVEL_X, NEXT_LEVEL_Y, NEXT_LEVEL_W, NEXT_LEVEL_H)) {
				// next level
				StateGameplay.showHint = false;
				StateLoading.loadingtype = StateLoading.LOADING_TYPE_GAME_TO_GAME;
			
				MainActivity.changeState(STATE_LOADING);

			} else if (isTouchReleaseInRect(RETRY_X, RETRY_Y, RETRY_W, RETRY_H)) {
				StateGameplay.showHint = false;
				StateLoading.loadingtype = StateLoading.LOADING_TYPE_GAME_TO_GAME;
			
				MainActivity.changeState(STATE_LOADING);
			} else if (isTouchReleaseInRect(MAIN_MENU_X, MAIN_MENU_Y, MAIN_MENU_W, MAIN_MENU_H)) {
				changeState(STATE_MAINMENU);
			}

			break;
		case MESSAGE_PAINT:

			Matrix matrix = new Matrix();
			if (!isGamePause) {
				mainCanvas.drawBitmap(splashImage, matrix, null);
				mainCanvas.drawColor(0xAd222222);
			} else {
				StateGameplay.SendMessageGameplay(MESSAGE_PAINT);
				mainCanvas.drawColor(0xFd222222);
			}
			fontsmall.drawString(mainCanvas, mainGameLib.getResources().getString(R.string.STRING_LEVEL_COMPLETE), SCREEN_WIDTH >> 1, (SCREEN_HEIGHT >> 1) - 60, 400, 2);
			// next level
			fontsmall.drawString(mainCanvas, "NEXT LEVEL", NEXT_LEVEL_X + NEXT_LEVEL_W / 2, NEXT_LEVEL_Y + NEXT_LEVEL_H / 2, 350, 2);
			mainCanvas.drawRect(NEXT_LEVEL_X, NEXT_LEVEL_Y, NEXT_LEVEL_X + NEXT_LEVEL_W, NEXT_LEVEL_Y + NEXT_LEVEL_H, mainPaint);
			// retry
			fontsmall.drawString(mainCanvas, "RETRY", RETRY_X + RETRY_W / 2, RETRY_Y + RETRY_H / 2, 350, 2);
			mainCanvas.drawRect(RETRY_X, RETRY_X, RETRY_X + RETRY_W, RETRY_Y + RETRY_H, mainPaint);
			// main menu
			fontsmall.drawString(mainCanvas, "MAIN MENU", MAIN_MENU_X + MAIN_MENU_W / 2, MAIN_MENU_Y + MAIN_MENU_H / 2, 350, 2);
			mainCanvas.drawRect(MAIN_MENU_X, MAIN_MENU_Y, MAIN_MENU_X + MAIN_MENU_W, MAIN_MENU_Y + MAIN_MENU_H, mainPaint);

			break;
		case MESSAGE_DTOR:

			break;
		}
	}

}
